#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>

//struct ThreadNum1
//{
//    int thread_num_;
//};
class ThreadNum1
{
    public:
        ThreadNum1()
        {

        }
        ~ThreadNum1()
        {

        }
        void SetTreadNum1(int num)
        {
            thread_num_ = num;
        }
        int GetThreadNum1()
        {
            return thread_num_;
        }
    private:
        int thread_num_;
};
void* pthread_start(void* arg)
{
    ThreadNum1*  tn = (ThreadNum1*)arg;
    while(1)
    {
        printf("i am pthread_start,i:%d\n",tn->GetThreadNum1());
        sleep(1);
    }
}

int main()
{
    pthread_t pht;
    for(int i = 0; i < 2; i++)
    {
        ThreadNum1* tn = new ThreadNum1();
        //struct GetThreadNum1* tn = new ThreadNum1;
        //if(tn == NULL)
        //{
        //    exit(1);
        //}
        //tn->thread_num_=i;
        tn->SetTreadNum1(i);
        int ret = pthread_create(&pht,NULL,pthread_start,(void*)tn);
        if(ret != 0)
        {
            perror("pthread_create\n");
            return 0;
        }
    }
    while(1)
    {
        printf("i am main pthead\n");
        sleep(1);
    }
    return 0;
}
